#include "HAL.h"

static const char *TAG = "HAL";

static int SPI_BUS_INIT()
{
    esp_err_t ret;
    spi_bus_config_t bus_cfg = {
        .mosi_io_num = PIN_NUM_MOSI,
        .miso_io_num = PIN_NUM_MISO,
        .sclk_io_num = PIN_NUM_CLK,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = 4000,
    };

    ret = spi_bus_initialize(PUBLIC_SPI_HOST, &bus_cfg, SPI_DMA_CH_AUTO);
    if (ret != ESP_OK) 
    {
        ESP_LOGE(TAG, "Failed to initialize bus.");
        return 1;
    }
    return 0;
}

void HAL_Init()
{
    SPI_BUS_INIT();
    RTC_Init();
    // Asw3410_Init();
    // NandFlash_Init();
    RJMU_Crypto_Init();
}